package routes

import (
	"github.com/gin-gonic/gin"
	adminController "last/app/controllers/v1/admin"
	"last/app/controllers/v1/admin/auth"
	"last/app/middlewares/jwt"
)

// RegisterAdminRoutes 注册路由
func RegisterAdminRoutes(r *gin.Engine) {
	v1 := r.Group("/v1")

	admin := v1.Group("/admin")

	login := adminController.LoginController{}
	//登陆
	admin.POST("login", login.Login)

	//jwt admin
	adminAuth := admin.Group("", jwt.JwtAuth())
	{
		adminMe := auth.AdminMeController{}
		//用户信息
		adminAuth.GET("me", adminMe.Me)

		//文章
		cate := auth.CategoryController{}
		//新增
		adminAuth.POST("category", cate.Store)

		//列表
		adminAuth.GET("category", cate.List)

		//详情
		adminAuth.GET("category/:id", cate.Show)

		//删除
		adminAuth.DELETE("category/:id", cate.Remove)

		//更新
		adminAuth.PUT("category", cate.Edit)

		//活动
		social := auth.SocialController{}
		//新增
		adminAuth.POST("social", social.Store)

		//列表
		adminAuth.GET("social", social.List)

		//详情
		adminAuth.GET("social/:id", social.Show)

		//删除
		adminAuth.DELETE("social/:id", social.Remove)

		//更新
		adminAuth.PUT("social", social.Edit)

		//网站设置
		site := auth.SiteController{}
		//新增
		adminAuth.POST("site", site.Store)

		//列表
		adminAuth.GET("site", site.List)

		//详情
		adminAuth.GET("site/:id", site.Show)

		//删除
		adminAuth.DELETE("site/:id", site.Remove)

		//更新
		adminAuth.PUT("site", site.Edit)

		//焦点
		focus := auth.FocusController{}
		//新增
		adminAuth.POST("focus", focus.Store)

		//列表
		adminAuth.GET("focus", focus.List)

		//详情
		adminAuth.GET("focus/:id", focus.Show)

		//删除
		adminAuth.DELETE("focus/:id", focus.Remove)

		//更新
		adminAuth.PUT("focus", focus.Edit)

		//友情链接
		friend := auth.FriendController{}
		//新增
		adminAuth.POST("friend", friend.Store)

		//列表
		adminAuth.GET("friend", friend.List)

		//详情
		adminAuth.GET("friend/:id", friend.Show)

		//删除
		adminAuth.DELETE("friend/:id", friend.Remove)

		//更新
		adminAuth.PUT("friend", friend.Edit)

		//文章
		post := auth.PostController{}
		//新增
		adminAuth.POST("post", post.Store)

		//列表
		adminAuth.GET("post", post.List)

		//详情
		adminAuth.GET("post/:id", post.Show)

		//删除
		adminAuth.DELETE("post/:id", post.Remove)

		//更新
		adminAuth.PUT("post", post.Edit)
	}
}
